import 'package:flutter/material.dart';
import 'package:happy_elf_app/utils/adaption.dart';

class HeaderBack extends StatefulWidget {
  const HeaderBack({Key? key, this.callback, this.title, this.isFirst})
      : super(key: key);

  final Function? callback;
  final String? title;
  final bool? isFirst;

  @override
  State<HeaderBack> createState() => _HeaderBackState();
}

class _HeaderBackState extends State<HeaderBack>
    with SingleTickerProviderStateMixin {
  late AnimationController _controller;

  @override
  void initState() {
    super.initState();
    _controller = AnimationController(vsync: this);
  }

  @override
  void dispose() {
    _controller.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Container(
      margin: EdgeInsets.only(top: 64.px),
      height: 100.px,
      child: Row(
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        children: [
          widget.isFirst!
              ? IconButton(
                  icon: const Icon(Icons.arrow_back_ios, color: Colors.black),
                  onPressed: () {
                    widget.callback!();
                  },
                )
              : SizedBox(width: 100.px),
          Text(
            widget.title ?? '',
            style: const TextStyle(
                color: Colors.black, // 标题颜色
                fontSize: 18,
                fontWeight: FontWeight.w500),
          ),
          SizedBox(width: 100.px)
        ],
      ),
    );
  }
}
